---
title: "Dashboard for NY NOAA dataset"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source_code: embed
---
```{r setup, include=FALSE}
library(tidyverse)
library(dplyr)
library(plotly)
library(p8105.datasets)
data("ny_noaa")
```
```{r}
ny_noaa = ny_noaa %>%
janitor::clean_names() %>%
separate(date, into = c("year", "month", "day"), sep = '-') %>%
drop_na(prcp, tmax, tmin, snow, snwd) %>%
mutate(tmax = as.numeric(tmax),
tmin = as.numeric(tmin),
tmax_c = tmax/10,
tmin_c = tmin/10,
prcp_mm = prcp/10,
month = recode(month, "01" = "January", "02" = "February", "03" = "March", "04" = "April", "05" = "May", "06" = "June", "07" = "July", "08" = "August", "09" = "September", "10" = "October", "11" = "November", "12" = "December"))
avg_max_temp_Jan = ny_noaa %>%
group_by(id, month, year) %>%
filter (month=="January") %>%
summarize (average_tmax = mean(tmax_c), na.rm=TRUE)
avg_max_temp_month = ny_noaa %>%
filter(year == "1994") %>%
mutate(month = factor(month, levels = month.name)) %>%
arrange(month) %>%
group_by(month) %>%
summarize (average_tmax = mean(tmax_c), na.rm=TRUE)
max_temp_month_2007 = ny_noaa %>%
filter(year == "1994") %>%
group_by(month, id, tmax_c) %>%
summarise()
```
Column {data-width=650}
-----------------------------------------------------------------------
```{r}
avg_max_temp_Jan %>%
plot_ly(
x = ~year, y = ~average_tmax, type = "scatter", mode = "markers", alpha = 0.5) %>%
layout(title = 'Scatterplot showing average maximum temperature in January')
```
Column {data-width=350}
-----------------------------------------------------------------------
```{r}
avg_max_temp_month %>%
plot_ly(x = ~month, y = ~average_tmax, color = ~month, type = "bar", colors = "viridis") %>%
layout(title = 'Barplot showing the average maximum temperature for each month in 1994')
```
```{r}
max_temp_month_2007 %>%
mutate(month = factor(month, levels = month.name)) %>%
arrange(month) %>%
plot_ly(y = ~tmax_c, color = ~month, type = "box", colors = "viridis") %>%
layout(title = 'Boxplot showing the range of values for the average maximum temperature for each month in 1994')
```